﻿<div class="list-block" style="margin: 0;" ms-controller="KHMP">
    <ul ms-if="isHasDataQX=='Y'">
        <!--<li>
            <div class="item-content item-link">
                <div class="item-inner">
                    <div class="item-title label">客户</div>
                    <div class="item-input">
                        <select ms-duplex="modelData.KHID" class="szhl szhl_require">
                            <option value="0"></option>
                            <option ms-repeat-item="ColumnData" ms-attr-value="item.ID" ms-attr-selected="item.ID==modelData.KHID?'selected':''">{{item.KHName}}</option>
                        </select>
                    </div>
                </div>
            </div>
        </li>-->
        <li>
            <div class="item-content ">
                <div class="item-inner">
                    <div class="item-title label">姓名</div>
                    <div class="item-input">
                        <input ms-duplex="modelData.UserXM" type="text" placeholder="请输入姓名" class="szhl szhl_require" />
                    </div>
                </div>
            </div>
        </li>
        <li>
            <div class="item-content">
                <div class="item-inner">
                    <div class="item-title label">手机</div>
                    <div class="item-input">
                        <input ms-duplex="modelData.TelePhone" type="text" placeholder="请输入手机" class="szhl szhl_require" />

                    </div>
                </div>
            </div>
        </li>
        <li>
            <div class="item-content">
                <div class="item-inner">
                    <div class="item-title label">电话</div>
                    <div class="item-input">
                        <input ms-duplex="modelData.MobilePhone" type="text" placeholder="请输入电话" />

                    </div>
                </div>
            </div>
        </li>
        <li>
            <div class="item-content">
                <div class="item-inner">
                    <div class="item-title label">分机</div>
                    <div class="item-input">
                        <input ms-duplex="modelData.Extension" type="text" placeholder="请输入分机" />

                    </div>
                </div>
            </div>
        </li>
        <li>
            <div class="item-content">
                <div class="item-inner">
                    <div class="item-title label">传真</div>
                    <div class="item-input">
                        <input ms-duplex="modelData.FixNo" type="text" placeholder="请输入传真" />

                    </div>
                </div>
            </div>
        </li>
        <li>
            <div class="item-content item-link">
                <div class="item-inner">
                    <div class="item-title label">性别</div>
                    <div class="item-input">
                        <select ms-duplex="modelData.UserSex">
                            <option value="">请选择性别</option>
                            <option value="男">男</option>
                            <option value="女">女</option>
                        </select>
                    </div>
                </div>
            </div>
        </li>
        <li>
            <div class="item-content">
                <div class="item-inner">
                    <div class="item-title label">学历</div>
                    <div class="item-input">
                        <input ms-duplex="modelData.Education" type="text" placeholder="请输入学历" />

                    </div>
                </div>
            </div>
        </li>
        <li>
            <div class="item-content">
                <div class="item-inner">
                    <div class="item-title label">公司</div>
                    <div class="item-input">
                        <input ms-duplex="modelData.Company" type="text" placeholder="请输入公司" />

                    </div>
                </div>
            </div>
        </li>
        <li>
            <div class="item-content">
                <div class="item-inner">
                    <div class="item-title label">部门</div>
                    <div class="item-input">
                        <input ms-duplex="modelData.Department" type="text" placeholder="请输入部门" />

                    </div>
                </div>
            </div>
        </li>
        <li>
            <div class="item-content">
                <div class="item-inner">
                    <div class="item-title label">职位</div>
                    <div class="item-input">
                        <input ms-duplex="modelData.Position" type="text" placeholder="请输入职位" />

                    </div>
                </div>
            </div>
        </li>
        <li>
            <div class="item-content">
                <div class="item-inner">
                    <div class="item-title label">邮箱</div>
                    <div class="item-input">
                        <input ms-duplex="modelData.EMail" type="text" placeholder="请输入邮箱" />

                    </div>
                </div>
            </div>
        </li>
        <li>
            <div class="item-content">
                <div class="item-inner">
                    <div class="item-title label">信箱</div>
                    <div class="item-input">
                        <input ms-duplex="modelData.Mailbox" type="text" placeholder="请输入信箱" />

                    </div>
                </div>
            </div>
        </li>
        <li>
            <div class="item-content">
                <div class="item-inner">
                    <div class="item-title label">QQ</div>
                    <div class="item-input">
                        <input ms-duplex="modelData.QQ" type="text" placeholder="请输入QQ" />

                    </div>
                </div>
            </div>
        </li>
        <li>
            <div class="item-content">
                <div class="item-inner">
                    <div class="item-title label">微信</div>
                    <div class="item-input">
                        <input ms-duplex="modelData.Weixin" type="text" placeholder="请输入微信" />

                    </div>
                </div>
            </div>
        </li>
        <li>
            <div class="item-content">
                <div class="item-inner">
                    <div class="item-title label">网址</div>
                    <div class="item-input">
                        <input ms-duplex="modelData.WebSite" type="text" placeholder="请输入网址" />

                    </div>
                </div>
            </div>
        </li>
        <li>
            <div class="item-content">
                <div class="item-inner">
                    <div class="item-title label">地址</div>
                    <div class="item-input">
                        <input ms-duplex="modelData.Address" type="text" placeholder="请输入地址" />

                    </div>
                </div>
            </div>
        </li>
        <li>
            <div class="item-content">
                <div class="item-inner">
                    <div class="item-title label">邮编</div>
                    <div class="item-input">
                        <input ms-duplex="modelData.PostCode" type="text" placeholder="请输入邮编" />

                    </div>
                </div>
            </div>
        </li>
        <li>
            <div class="item-content item-link">
                <div class="item-inner">
                    <div class="item-title label">生日</div>
                    <div class="item-input">
                        <input type="text" placeholder="请选择生日" id="appDate" ms-duplex="modelData.Birthday" />
                    </div>
                </div>
            </div>
        </li>
        <li>
            <div class="item-content">
                <div class="item-inner">
                    <div class="item-title label">其他</div>
                    <div class="item-input">
                        <textarea ms-duplex="modelData.Others" rows="3" placeholder="请输入其他"></textarea>

                    </div>
                </div>
            </div>
        </li>
        <li>
            <div class="item-content">
                <div class="item-inner">
                    <div class="item-title label">备注</div>
                    <div class="item-input">
                        <textarea ms-duplex="modelData.Remark" rows="3" placeholder="请输入备注"></textarea>

                    </div>
                </div>
            </div>
        </li>
        <li class="align-top">
            <div class="item-content">
                <div class="item-inner">
                    <div class="item-title label">图片</div>
                    <div class="item-input">
                        <input type="text" ms-duplex="modelData.Files" class="wximgupload" style="display:none;" />
                    </div>
                </div>
            </div>
        </li>
    </ul>

    <ul ms-if="isHasDataQX=='N'">
        <!--<li>
            <div class="item-content ">
                <div class="item-inner">
                    <div class="item-title label">客户</div>
                    <div class="item-input">
                        <div style=" line-height: 1.4; ">{{khname}}</div>
                    </div>
                </div>
            </div>
        </li>-->
        <li>
            <div class="item-content">
                <div class="item-inner">
                    <div class="item-title label">姓名</div>
                    <div class="item-input">

                        <div style="overflow: hidden; word-wrap: break-word; word-break: break-all; ">{{modelData.UserXM}}</div>
                    </div>
                </div>
            </div>
        </li>
        <li>
            <div class="item-content">
                <div class="item-inner">
                    <div class="item-title label">手机</div>
                    <div class="item-input">
                        <div style="overflow: hidden; word-wrap: break-word; word-break: break-all; ">{{modelData.TelePhone}}</div>
                    </div>
                </div>
            </div>
        </li>
        <li ms-if="modelData.MobilePhone">
            <div class="item-content">
                <div class="item-inner">
                    <div class="item-title label">电话</div>
                    <div class="item-input">
                        <div style="overflow: hidden; word-wrap: break-word; word-break: break-all; ">{{modelData.MobilePhone}}</div>
                    </div>
                </div>
            </div>
        </li>
        <li ms-if="modelData.Extension">
            <div class="item-content">
                <div class="item-inner">
                    <div class="item-title label">分机</div>
                    <div class="item-input">
                        <div style="overflow: hidden; word-wrap: break-word; word-break: break-all; ">{{modelData.Extension}}</div>
                    </div>
                </div>
            </div>
        </li>
        <li ms-if="modelData.FixNo">
            <div class="item-content">
                <div class="item-inner">
                    <div class="item-title label">传真</div>
                    <div class="item-input">
                        <div style="overflow: hidden; word-wrap: break-word; word-break: break-all; ">{{modelData.FixNo}}</div>
                    </div>
                </div>
            </div>
        </li>
        <li ms-if="modelData.UserSex">
            <div class="item-content">
                <div class="item-inner">
                    <div class="item-title label">性别</div>
                    <div class="item-input">
                        <div style="overflow: hidden; word-wrap: break-word; word-break: break-all; ">{{modelData.UserSex}}</div>
                    </div>
                </div>
            </div>
        </li>
        <li ms-if="modelData.Education">
            <div class="item-content">
                <div class="item-inner">
                    <div class="item-title label">学历</div>
                    <div class="item-input">
                        <div style="overflow: hidden; word-wrap: break-word; word-break: break-all; ">{{modelData.Education}}</div>
                    </div>
                </div>
            </div>
        </li>
        <li ms-if="modelData.Company">
            <div class="item-content">
                <div class="item-inner">
                    <div class="item-title label">公司</div>
                    <div class="item-input">
                        <div style="overflow: hidden; word-wrap: break-word; word-break: break-all; ">{{modelData.Company}}</div>
                    </div>
                </div>
            </div>
        </li>
        <li ms-if="modelData.Department">
            <div class="item-content">
                <div class="item-inner">
                    <div class="item-title label">部门</div>
                    <div class="item-input">
                        <div style="overflow: hidden; word-wrap: break-word; word-break: break-all; ">{{modelData.Department}}</div>
                    </div>
                </div>
            </div>
        </li>
        <li ms-if="modelData.Position">
            <div class="item-content">
                <div class="item-inner">
                    <div class="item-title label">职位</div>
                    <div class="item-input">
                        <div style="overflow: hidden; word-wrap: break-word; word-break: break-all; ">{{modelData.Position}}</div>
                    </div>
                </div>
            </div>
        </li>
        <li ms-if="modelData.EMail">
            <div class="item-content">
                <div class="item-inner">
                    <div class="item-title label">邮箱</div>
                    <div class="item-input">
                        <div style="overflow: hidden; word-wrap: break-word; word-break: break-all; ">{{modelData.EMail}}</div>
                    </div>
                </div>
            </div>
        </li>
        <li ms-if="modelData.Mailbox">
            <div class="item-content">
                <div class="item-inner">
                    <div class="item-title label">信箱</div>
                    <div class="item-input">
                        <div style="overflow: hidden; word-wrap: break-word; word-break: break-all; ">{{modelData.Mailbox}}</div>
                    </div>
                </div>
            </div>
        </li>
        <li ms-if="modelData.QQ">
            <div class="item-content">
                <div class="item-inner">
                    <div class="item-title label">QQ</div>
                    <div class="item-input">
                        <div style="overflow: hidden; word-wrap: break-word; word-break: break-all; ">{{modelData.QQ}}</div>
                    </div>
                </div>
            </div>
        </li>
        <li ms-if="modelData.Weixin">
            <div class="item-content">
                <div class="item-inner">
                    <div class="item-title label">微信</div>
                    <div class="item-input">
                        <div style="overflow: hidden; word-wrap: break-word; word-break: break-all; ">{{modelData.Weixin}}</div>
                    </div>
                </div>
            </div>
        </li>
        <li ms-if="modelData.WebSite">
            <div class="item-content">
                <div class="item-inner">
                    <div class="item-title label">网址</div>
                    <div class="item-input">
                        <div style="overflow: hidden; word-wrap: break-word; word-break: break-all; ">{{modelData.WebSite}}</div>
                    </div>
                </div>
            </div>
        </li>
        <li ms-if="modelData.Address">
            <div class="item-content">
                <div class="item-inner">
                    <div class="item-title label">地址</div>
                    <div class="item-input">
                        <div style="overflow: hidden; word-wrap: break-word; word-break: break-all; ">{{modelData.Address}}</div>
                    </div>
                </div>
            </div>
        </li>
        <li ms-if="modelData.PostCode">
            <div class="item-content">
                <div class="item-inner">
                    <div class="item-title label">邮编</div>
                    <div class="item-input">
                        <div style="overflow: hidden; word-wrap: break-word; word-break: break-all; ">{{modelData.PostCode}}</div>
                    </div>
                </div>
            </div>
        </li>
        <li ms-if="modelData.Birthday">
            <div class="item-content">
                <div class="item-inner">
                    <div class="item-title label">生日</div>
                    <div class="item-input">
                        <div style="overflow: hidden; word-wrap: break-word; word-break: break-all; ">{{modelData.Birthday}}</div>
                    </div>
                </div>
            </div>
        </li>
        <li ms-if="modelData.Others">
            <div class="item-content">
                <div class="item-inner">
                    <div class="item-title label">其他</div>
                    <div class="item-input">
                        <div style="overflow: hidden; word-wrap: break-word; word-break: break-all; ">{{modelData.Others|html}}</div>
                    </div>
                </div>
            </div>
        </li>
        <li ms-if="modelData.Remark">
            <div class="item-content">
                <div class="item-inner">
                    <div class="item-title label">备注</div>
                    <div class="item-input">
                        <div style="overflow: hidden; word-wrap: break-word; word-break: break-all; ">{{modelData.Remark|html}}</div>
                    </div>
                </div>
            </div>
        </li>
        <li class="align-top" ms-if="modelData.Files">
            <div class="item-content">
                <div class="item-inner">
                    <div class="item-title label">图片</div>
                    <div class="item-input">
                        <div class="viewimg">{{modelData.Files}}</div>
                    </div>
                </div>
            </div>
        </li>
    </ul>

</div>

<script>
    var tempmodel = avalon.define({
        $id: "KHMP",
        ColumnData: [],
        name: "名片管理",
        tpData: [],
        wximg: "",
        dataid: "",
        khname:"",
        khid: ComFunJS.getQueryString("khid"),
        inittemp: function (strId) {

            //$.getJSON('/API/VIEWAPI.ashx?Action=CRM_GETALLKH', {}, function (resultData) {
            //    if (resultData.ErrorMsg == "") {
            //        tempmodel.ColumnData = resultData.Result;
            //        if (tempmodel.khid) {
            //            tempmodel.modelData.KHID = tempmodel.rid
            //        } else if (!tempmodel.modelData.KHID) {
            //            tempmodel.modelData.KHID = resultData.Result[0].ID
            //        }
            //    }
            //})

            if (strId) {

                tempmodel.dataid = strId;
                $.getJSON('/API/VIEWAPI.ashx?Action=CRM_GETKHMPMODEL', { P1: strId }, function (resultData) {

                    if (resultData.ErrorMsg == "") {
                        tempmodel.modelData = resultData.Result;
                        tempmodel.khname = resultData.Result1;
                        tempmodel.tpData = resultData.Result2;

                        if (tempmodel.modelData.Birthday && tempmodel.modelData.Birthday.length > 10) {
                            tempmodel.modelData.Birthday = tempmodel.modelData.Birthday.substring(0, 10);

                            $("#appDate").calendar({
                                value: [tempmodel.modelData.Birthday]
                            });
                        }
                        else {
                            $("#appDate").calendar({
                                value: []
                            });
                        }


                        ComFunJS.uploadimgnew(tempmodel.tpData);
                        ComFunJS.viewimg(tempmodel.tpData);

                        setTimeout(" ComFunJS.initForm()", 500)
                    }
                })
            } else {
                $("#appDate").calendar({
                    value: []
                });

                ComFunJS.uploadimgnew();
                ComFunJS.initForm();
            }
        },//初始化
        modelData: { "KHID": "", "UserXM": "", "UserSex": "", "TelePhone": "", "Department": "", "Position": "", "EMail": "", "QQ": "", "Weixin": "", "Address": "", "Remark": "", "Files": "", "WebSite": "", "PostCode": "", "Birthday": "", "Extension": "", "FixNo": "", "Education": "", "Company": "", "Mailbox": "", "Others": "" },
        SaveData: function (callback) {

            tempmodel.modelData.Files = "";
            $("#imglist .tpli").each(function () {
                if ($(this).hasClass("wximg")) { //微信上传未处理的图片
                    if (tempmodel.wximg) {
                        tempmodel.wximg += ",";
                    }
                    tempmodel.wximg += $(this).attr("itemid");

                } else {
                    if (tempmodel.modelData.Files) {
                        tempmodel.modelData.Files = tempmodel.modelData.Files + ',' + $(this).attr("itemid");
                    }
                    else {
                        tempmodel.modelData.Files = $(this).attr("itemid");
                    }
                }

            })
            $.post("/API/VIEWAPI.ashx?ACTION=CRM_ADDKHMP", { P1: JSON.stringify(tempmodel.modelData.$model), P2: tempmodel.wximg }, function (result) {

                return callback.call(this, $.parseJSON(result));
            });
        },
        Complate: function () {
            window.location.href = "/View_Mobile/UI/CRM/UI_KHMP_LIST.html?r=" + Math.random();
        }
    });//@ sourceURL=MHYGL.js;

</script>